const mongoose = require("mongoose")
const mongoPath = 'mongodb://localhost:27017/pictures'
const { forest } = require('../public/statistic')
// 连接mongoDB
async function main(){
    await mongoose.connect(mongoPath)
}

main().then(res => {
    console.log('mongoDB连接成功')
}).catch( error => {
    console.log(error,'连接失败')
})
// 导出数据库模型
const forestSet = mongoose.model('forest',require('./pictureModel'))
const oceanSet = mongoose.model('ocean',require('./pictureModel'))
const kittySet = mongoose.model('kitty',require('./pictureModel'))
const setDate = () => {
    forest.forEach(item => {
        forestSet.create({
            title: item.title,
            photoType: item.photoType,
            author: item.author,
            authorPic: item.authorPic,
            authorLike: item.authorLike,
            photoLink: item.photoLink,
            photo: item.photo,
            aspectRatio: item.aspectRatio
        }, (err, res) => {
            console.log(res);
        })
    })
}



// const data = forestSet.find((err,result) => {
//     console.log(result);
// })

module.exports = {
    forestSet,
    oceanSet,
    kittySet
}
// setDate()

